package com.jthinker.bean.enu;

/**
 * User: Gang Chen
 * Date: 2015/4/13 21:38
 */
public enum CommentStatus implements Dict
{
    NOT_ALLOWED(0, "不允许"), ALLOWED(1, "允许");
    private int key;
    private String text;

    CommentStatus(int key, String text)
    {
        this.key = key;
        this.text = text;
    }

    public int getKey()
    {
        return key;
    }

    public String getText()
    {
        return text;
    }

    public static final CommentStatus parse(String keyStr)
    {
        int key;
        try
        {
            key = Integer.parseInt(keyStr);
        }
        catch (NumberFormatException e)
        {
            e.printStackTrace();
            return NOT_ALLOWED;
        }
        for (CommentStatus status : CommentStatus.values())
        {
            if (status.getKey() == key)
            {
                return status;
            }
        }

        return NOT_ALLOWED;
    }
}
